# -*- coding: utf-8 -*-
import sys
import time
from PySide6.QtCore import Signal, Qt
from PySide6.QtGui import QKeySequence, QShortcut, QFont
from PySide6.QtWidgets import QMainWindow, QApplication, QFileDialog
from loguru import logger

from plugins.iICLogParse_ui import Ui_IICLogParseMainWindow
from utils.strTools import append_or_blank, format_system_time, parse_bit_flags, \
    convert_hex_to_voltage, convert_hex_to_temperature
from utils.csvHandler import CsvHandler


class IICLogParseWindow(QMainWindow, Ui_IICLogParseMainWindow):
    """
    LOG解析
    """
    # 声明带一个字典类型参数的信号
    iICLogParseSignal = Signal(dict)
    script_path = None

    def __init__(self):
        super().__init__()
        # 加载UI
        self.setupUi(self)
        # 连接信号与槽
        self.SignalConnectInit()
        # 创建定时器
        self.TimerInit()
        # 添加快捷键
        self.ShortcutFun()
        # 引入公共程序
        from utils.common import commonProgram
        # 引入配置文件
        self.myConfig = commonProgram.EnableConfigHandler()
        print('IICLogParseWindow get config Version', self.myConfig.version)
        # 引入可控串口信息窗口
        # self.serialPortWin = commonProgram.EnableFt4222(winSignal=self.iICLogParseSignal)

    def CleanupSelf(self):
        """
        清理当前窗口并关闭，由其他其他程序调用
        :return:
        """
        try:
            self.close()  # 关闭当前窗口
            self.deleteLater()  # 释放子窗口资源
            print("PluginWindow.__del__.ok")
        except Exception as err:
            print("PluginWindow.__del__.error", err)

    def SignalConnectInit(self):
        """
        连接来自UI对象的信号与槽
        :return:
        """
        # QPushButton
        self.btnOpenLog.clicked.connect(self.OpenLogFun)
        self.btnParsePCLog.clicked.connect(self.ParseLogPCFun)
        self.btnParseHostLog.clicked.connect(self.ParseLogHostFun)

    def TimerInit(self):
        """
        定时器创建与信号连接
        此处添加了定时器，一定要在 `CleanupSelf`中添加注销操作，否则切换测试项时不会失效，会一直以子线程运行
        :return:
        """
        pass

    def ShortcutFun(self):
        """
        快捷键 F11 全屏
        快捷键 F5 清屏
        :return:
        """
        # 快捷键 F11
        self.screenStatus = 'Normal'
        screenShortcut = QShortcut(QKeySequence(Qt.Key_F11), self)
        screenShortcut.activated.connect(self.WindowSizeFun)
        self.setToolTip('全屏与退出全屏：\n               双击 或者 F11')
        # 快捷键 F5
        # screenShortcut2 = QShortcut(QKeySequence(Qt.Key_F5), self)
        # screenShortcut2.activated.connect(self.CleanFun)

    def WindowSizeFun(self):
        """
        控制窗口尺寸，此处为原大小（最小UI布局）或者全屏
        :return:
        """
        if self.screenStatus == 'Normal':
            self.showFullScreen()
            self.screenStatus = 'FullScreen'
        else:
            self.showNormal()
            self.screenStatus = 'Normal'

    def SendDataHandle(self, dataDict: dict):
        """
        发送信号或数据处理函数
        :param dataDict:
        :return:
        """
        # 发送信号处理
        dataObj = dataDict.get('data', '')
        typeValue = dataDict.get('type', 'null').strip()
        # 本窗口发送数据
        self.iICLogParseSignal.emit(dataDict)
        # do something
        logger.info(f"{typeValue} \t {dataObj}")

    def OpenLogFun(self):
        self.lineEditLogPath.clear()
        # 创建文件对话框
        file_dialog = QFileDialog(self)
        # 设置文件过滤器，仅允许选择 CSV 文件
        # file_dialog.setNameFilter("CSV Files (*.csv)")
        # 打开文件对话框，并获取选中的文件路径
        self.script_path, _ = file_dialog.getOpenFileName(
            self,
            "Open LOG File",
            "data",
            "CSV Files (*.csv);;BIN Files (*.bin);;TEXT Files (*.txt);;All Files (*.*)"
        )
        if not self.script_path:
            myText = '未打开任何文件 {}'.format(str(self.script_path))
            dictData = {"data": myText, "type": f"status_show"}
            self.SendDataHandle(dictData)
            return
        myText = '文件已经打开：{}'.format(str(self.script_path))
        dictData = {"data": myText, "type": f"status_show"}
        self.SendDataHandle(dictData)
        self.lineEditLogPath.setText(self.script_path)
        self.statusbar.showMessage(myText)

    def ParseCSVPCFun(self):
        self.script_new_path = self.script_path[:-4] + '_readable.csv'
        if self.radioC01P03.isChecked():
            self.horizontalHeaderList = ["索引", "时间戳", "Log存储原因_Low", "Log存储原因_High", "电压AD值",
                                         "PCB温度AD值", "TFT温度AD值", "MCU内部软件版本", "开关信息", "状态信息",
                                         "复位原因", "TDDI固件版本", "TP初始化状态", "TP故障码", "TCON故障",
                                         "TFT初始化状态", "TFT故障码", "TFT故障码", "背光亮度值-主机",
                                         "背光亮度值-当前", "背光故障码", "旋转机构软件版本", "主机发的角度",
                                         "实际的角度", "旋转机构故障码", "机构运动状态", "系统时间", "预留", "Checksum"]
        else:
            self.horizontalHeaderList = ["索引", "时间戳", "Log存储原因_Low", "Log存储原因_High", "电压AD值",
                                         "PCB温度AD值", "TFT温度AD值", "MCU内部软件版本", "开关信息", "状态信息",
                                         "复位原因", "TDDI固件版本", "TP初始化状态", "TP故障码", "TFT初始化状态",
                                         "TFT故障码", "TFT故障码", "背光亮度值-主机", "背光亮度值-当前",
                                         "背光故障码_Low", "背光故障码_High", "旋转机构软件版本", "主机发的角度",
                                         "实际的角度", "旋转机构故障码", "机构运动状态", "TCON版本号", "TCON故障码_1",
                                         "TCON故障码_2", "TCON故障码_3", "系统时间", "预留", "Checksum"]
        self.csvHandler: CsvHandler = CsvHandler()
        self.csvHandler.runData.append(self.horizontalHeaderList)
        self.csvHandler.verticalHeaderCount = len(self.csvHandler.horizontalHeaderList)
        self.csvHandler.read_csv(filename=self.script_path, dropFirstLine=False)
        for row in self.csvHandler.csvData:
            listData = []
            # 索引
            log_idx = row[1] + row[0]
            obj_idx = int(log_idx, 16)
            listData.append(obj_idx)

            # 时间戳
            # log_time = f"{int(row[2], 16)}-{int(row[3], 16)}-{int(row[4], 16)} {int(row[5], 16)}:{int(row[6], 16)}:{int(row[7], 16)}"
            log_time = f"{row[2]}-{row[3]}-{row[4]} {row[5]}:{row[6]}:{row[7]}"
            listData.append(log_time)

            # 触发存储的原因
            log_save_low = row[8]
            log_save_low_descriptions = [
                "L_bit0：开关信息触发", "L_bit1：状态信息触发（电源状态和LOCK）", "L_bit2：TP故障码触发",
                "L_bit3：TFT故障码触发", "L_bit4：背光亮度值触发", "L_bit5：背光故障码触发", "L_bit6：主机发的机构角度触发",
                "L_bit7：机构故障码触发"]
            log_save_low_bits = format(int(log_save_low, 16), '08b')
            obj_save_bit_list = parse_bit_flags(log_save_low_bits, log_save_low_descriptions)
            listData.append(obj_save_bit_list)

            # 触发存储的原因
            log_save_high = row[9]
            log_save_high_descriptions = [
                "H_bit0：机构运动状态改变触发记录", "H_bit1：十分钟周期触发记录", "-", "-", "-", "-", "-", "-"]
            log_save_high_bits = format(int(log_save_high, 16), '08b')
            obj_save_bit_list_high = parse_bit_flags(log_save_high_bits, log_save_high_descriptions)
            listData.append(obj_save_bit_list_high)

            # 电压AD值
            log_power_adc = row[11] + row[10]
            obj_power_adc = convert_hex_to_voltage(log_power_adc)
            listData.append(obj_power_adc)

            # PCB温度AD值
            log_pcb_adc = row[13] + row[12]
            obj_pcb_adc = convert_hex_to_temperature(log_pcb_adc)
            listData.append(obj_pcb_adc)

            # TFT温度AD值
            log_tft_adc = row[15] + row[14]
            obj_tft_adc = convert_hex_to_temperature(log_tft_adc)
            listData.append(obj_tft_adc)

            # MCU内部软件版本
            log_mcu_version = f"{row[16]}-{row[17]}-{row[18]}"
            listData.append(log_mcu_version)

            # 开关信息
            log_switch = row[19]
            log_switch_descriptions = [
                "bit0：背光模式(1：开)，主机发的",
                "bit1：背光模式(1：开)，经过IIC、电压、温度、使能等背光控制的",
                "-",
                "-",
                "-",
                "-",
                "-",
                "-",
            ]
            log_switch_bits = format(int(log_switch, 16), '08b')
            obj_switch_bit_list = parse_bit_flags(log_switch_bits, log_switch_descriptions)
            listData.append(obj_switch_bit_list)

            # 状态信息
            log_status = row[20]
            if self.radioC01P03.isChecked():
                descr = ["0：dInit", "1：dOff", "2：dDelay20s", "3：dDelay60s", "4：dStandby", "5：dOn", "6：dMax", ]

            else:
                log_status = row[20]
                descr = ["0：dDimmingOff", "1：dRetain20s", "2：dRetain60s", "3：dTempFallDerating",
                         "4：dTempRaiseDeratingOrNormal", "5：dTypeMax"]
            hex_value = int(log_status, 16)  # 将十六进制字符串转换为十进制整数
            log_status_bits = format(hex_value, '08b')  # 将十进制整数转换为二进制字符串，并保持8位长度
            status_value = int(log_status_bits[1:], 2)  # 取0到6位并将其转换为十进制整数
            lock_value = int(log_status_bits[:1], 2)  # 取0到6位并将其转换为十进制整数
            obj_status_bit_list = []
            obj_status_bit_list.append(descr[status_value])
            obj_status_bit_list.append("Vedio-Lock 1：异常") if lock_value else obj_status_bit_list.append(
                "Vedio-Lock 0：正常")
            listData.append(obj_status_bit_list)

            # 复位原因
            obj_reset = row[21]
            data_strings = [
                "-, 0",
                "MCU_SW_RESET, 1",
                "MCU_WATCHDOG0_RESET, 2",
                "MCU_WATCHDOG1_RESET, 3",
                "MCU_CLM0_RESET, 4",
                "MCU_CLM1_RESET, 5",
                "MCU_CLM2_RESET, 6",
                "MCU_LVI_RESET, 7",
                "MCU_CVM_RESET, 8",
                "MCU_TERMINAL_RESET, 9",
                "MCU_POWER_ON_RESET, A",
                "MCU_ISO_RESET, B",
                "MCU_RESF11_RESET, C",
                "MCU_RESF12_RESET, D",
                "MCU_RESF13_RESET, E",
                "MCU_CLM3_RESET, F",
                "MCU_RESET_UNDEFINED, 10",
                "MCU_MULTIPLE_RESETS_OCCURED, 11",
                "MCU_RESET_UNKNOWN, 12",
            ]
            listData.append(f"{data_strings[int(obj_reset, 16)]}")

            # TDDI固件版本
            obj_tp_version = f"{row[22]}.{row[27]}.{row[23]}"
            listData.append(f"{obj_tp_version}")

            # TP初始化状态
            log_tp_init = row[24]
            obj_tp_init = f"{'1：失败' if int(log_tp_init, 16) else '0：成功'}"
            listData.append(obj_tp_init)

            # TP故障码
            log_TPError = row[25]
            log_TPError_descriptions = [
                "bit0：开路(1：开路)",
                "bit1：短路(1：短路)",
                "-",
                "-",
                "-",
                "-",
                "-",
                "-",
            ]
            log_TPError_bits = format(int(log_TPError, 16), '08b')
            obj_TPError_bit_list = parse_bit_flags(log_TPError_bits, log_TPError_descriptions)
            listData.append(obj_TPError_bit_list)

            # TCON故障
            if self.radioC01P03.isChecked():
                log_TCONError = row[26]
                log_TCONError_descriptions = [
                    "bit0：CRC frozen（CRC校验冻结故障）",
                    "bit1：Fail flag from GPlOx. (lf rom code enabled)（GPIO-X错误）",
                    "bit2：Fail flag from GPlOy. (lf rom code enabled)（GPIO-Y错误）",
                    "bit3：RX fail - No DE detected.（检测到没有视频输入）",
                    "bit4：RX fail - DE Error detected.（检测到视频信号输入错误）",
                    "bit5：RX fail detected.（视频信号输入错误）",
                    "bit6：Rom code download fai.（TCON flash代码读取错误故障）",
                    "bit7：Video CRC error detected.Uf rom code enabled)（视频信号校验错误）",
                ]
                log_TCONError_bits = format(int(log_TCONError, 16), '08b')
                obj_TCONError_bit_list = parse_bit_flags(log_TCONError_bits, log_TCONError_descriptions)
                listData.append(obj_TCONError_bit_list)

            # TFT初始化状态
            log_tft_init = row[29]
            obj_tft_init = f"{'1：失败' if int(log_tft_init, 16) else '0：成功'}"
            listData.append(obj_tft_init)

            # TFT故障码_L
            log_TFT_LError = row[30]
            log_TFT_LError_descriptions = [
                "bit0：低压(1：异常)",
                "bit1：LVDS信号异常(1：异常)",
                "bit2：Otp故障(1：异常)",
                "bit3：超温(1：异常)",
                "bit4：过压(1：异常)",
                "bit5：flashReloadError(1：异常)",
                "bit6：Tcon错误(1：异常)",
                "bit7：Gate错误(1：异常)"
            ]
            log_TFT_LError_bits = format(int(log_TFT_LError, 16), '08b')
            obj_TFT_LError_bit_list = parse_bit_flags(log_TFT_LError_bits, log_TFT_LError_descriptions)
            listData.append(obj_TFT_LError_bit_list)

            # TFT故障码_H
            log_TFT_HError = row[31]
            log_TFT_HError_descriptions = [
                "bit0：TDDI Pin故障(1：异常)",
                "bit1：crcError(1：异常)",
                "bit2：pwm故障(1：异常)",
                "bit3：VghVglClkFb(1：异常)",
                "bit4：checksum或者配置错误(1：异常)",
                "bit5：sdOutFail/ponDetectFail(1：异常)",
                "bit6：看门狗超时(1：异常)",
                "bit7：poweronFail/slave ic Fail(1：异常)"
            ]
            log_TFT_HError_bits = format(int(log_TFT_HError, 16), '08b')
            obj_TFT_HError_bit_list = parse_bit_flags(log_TFT_HError_bits, log_TFT_HError_descriptions)
            listData.append(obj_TFT_HError_bit_list)

            # 背光亮度值，主机发的
            obj_host_backlight = row[32]
            listData.append(f"{int(obj_host_backlight, 16)} ({obj_host_backlight})")

            # 背光亮度值，当前的
            obj_curr_backlight = row[33]
            listData.append(f"{int(obj_curr_backlight, 16)} ({obj_curr_backlight})")

            # 背光故障码
            if self.radioC01P03.isChecked():
                log_backlightError = row[34]
                log_backlightError_descriptions = [
                    "bit0：开路(1：开路)",
                    "bit1：短路(1：短路)",
                    "bit2：低压(1：异常)",
                    "bit3：高压(1：异常)",
                    "bit4：过流(1：异常)",
                    "bit5：IIC错误(1：异常)",
                    "-", "-"
                ]
                log_backlightError_bits = format(int(log_backlightError, 16), '08b')
                obj_backlightError_bit_list = parse_bit_flags(log_backlightError_bits, log_backlightError_descriptions)
                listData.append(obj_backlightError_bit_list)
            else:
                log_backlightError_l = row[34]
                log_backlightError_descriptions = [
                    "[0]: driver error",
                    "-",
                    "-",
                    "-",
                    "-",
                    "-",
                    "-",
                    "-"
                ]
                log_backlightError_bits = format(int(log_backlightError_l, 16), '08b')
                obj_backlightError_bit_list = parse_bit_flags(log_backlightError_bits, log_backlightError_descriptions)
                listData.append(obj_backlightError_bit_list)

                log_backlightError_h = row[35]
                log_backlightError_descriptions = [
                    "[0]: LED driver 1~8 status",
                    "[1]:LED driver 9~16 status",
                    "[2]:LED driver 17~24status",
                    "[3]: LED driver 25~32status",
                    "[4]: LED driver 33~40status",
                    "[5]:LED driver 41~48status",
                    "[6], LED driver 49~56status",
                    "[7]:LED driver 57~64status"
                ]
                log_backlightError_bits = format(int(log_backlightError_h, 16), '08b')
                obj_backlightError_bit_list = parse_bit_flags(log_backlightError_bits, log_backlightError_descriptions)
                listData.append(obj_backlightError_bit_list)

            # 旋转机构软件版本
            obj_motor_version = f" V{int(row[48], 16)}.{int(row[49], 16)}"
            listData.append(obj_motor_version)

            # 主机发的角度
            log_host_angle = row[50]
            obj_host_angle = f"{int(log_host_angle, 16)}° ({log_host_angle})"
            listData.append(obj_host_angle)

            # 实际的角度
            log_return_angle = row[51]
            obj_return_angle = f"{int(log_return_angle, 16)}° ({log_return_angle})"
            listData.append(obj_return_angle)

            # 旋转机构故障码
            log_MotorError = row[52]
            log_MotorError_descriptions = [
                "-", "-", "bit2：串口通讯状态(1：异常)", "bit3：高温故障(1：异常)",
                "bit4：低温故障(1：异常)", "bit5：电机缺相(1：异常)",
                "bit6：电机堵转(1：异常)", "bit7：电压异常(1：异常)"
            ]
            log_MotorError_bits = format(int(log_MotorError, 16), '08b')
            obj_MotorError_bit_list = parse_bit_flags(log_MotorError_bits, log_MotorError_descriptions)
            listData.append(obj_MotorError_bit_list)

            # 机构运动状态
            obj_motor_status = row[53]
            data_strings = [
                "0x00：展开操作",
                "0x01：收起操作",
                "0x02：停止",
            ]
            int_value = int(obj_motor_status, 16)
            listData.append(f"{data_strings[int_value] if int_value < len(data_strings) else obj_motor_status}")

            if self.radioC01P03.isChecked():
                # 系统时间
                log_sys_time = row[57] + row[56] + row[55] + row[54]
                obj_sys_time = format_system_time(log_sys_time)
                listData.append(obj_sys_time)
            else:
                # TCON版本号
                obj_tcon_version = f"{row[54]} {row[55]}"
                listData.append(obj_tcon_version)

                # TCON故障码_1
                obj_tcon_error_1 = row[56]
                log_tcon_error_descriptions = [
                    "[0]: TCON PIN FAIL",
                    "[1]:",
                    "[2]: Fail flag from GPlOx, (lf rom code enabled)",
                    "[3]: Fail flag from GPlOy, (if rom code enabled)",
                    "[4]: Panel crack,(lf rom code enabled)",
                    "[5]: RX fail",
                    "[6]: Download fail",
                    "[7]: VideoCRC error detection, (lf rom code enabled)"
                ]
                log_tcon_error_1 = format(int(obj_tcon_error_1, 16), '08b')
                obj_tcon_error_1_list = parse_bit_flags(log_tcon_error_1, log_tcon_error_descriptions)
                listData.append(obj_tcon_error_1_list)

                # TCON故障码_2
                obj_tcon_error_2 = row[57]
                log_tcon_error_descriptions = [
                    "[0]: LDIPoutputfail",
                    "[1]:VLED OV. (For Maxim only)",
                    "[2]: VLED_UVLO. (For Maxim only)",
                    "[3]: CRC frozen.",
                    "[4]: LED thermal shutdown.",
                    "[5]: LED open.",
                    "[6], LED short.",
                    "[7]:LED other fail. (For Maxim only)"
                ]
                log_tcon_error_2 = format(int(obj_tcon_error_2, 16), '08b')
                obj_tcon_error_2_list = parse_bit_flags(log_tcon_error_2, log_tcon_error_descriptions)
                listData.append(obj_tcon_error_2_list)

                # TCON故障码_3"
                obj_tcon_error_3 = row[58]
                log_tcon_error_descriptions = [
                    "[0]: DEfail",
                    "[1]:NotDEerror",
                    "[2]: clockfail",
                    "[3]: HtotalVtotalover",
                    "[4]: SPI_A_communicatefail",
                    "[5]: SPI_B_communicatefail",
                    "[6], ",
                    "[7]:"
                ]
                log_tcon_error_3 = format(int(obj_tcon_error_3, 16), '08b')
                obj_tcon_error_3_list = parse_bit_flags(log_tcon_error_3, log_tcon_error_descriptions)
                listData.append(obj_tcon_error_3_list)

                # 系统时间
                log_sys_time = row[62] + row[61] + row[60] + row[59]
                obj_sys_time = format_system_time(log_sys_time)
                listData.append(obj_sys_time)

            # 输出一条结果
            self.csvHandler.runData.append(listData)

        sedMsg = '未保存文件'
        if self.script_new_path:
            self.csvHandler.save_csv(filename=self.script_new_path, listData=self.csvHandler.runData)
            sedMsg = '文件已保存：{}'.format(str(self.script_new_path))
        dictData = {"data": sedMsg, "type": f"status_show"}
        self.SendDataHandle(dictData)
        self.statusbar.showMessage(sedMsg)

    def ParseLogBINFun(self):
        self.script_new_path = self.script_path[:-4] + '_pc.csv'
        self.csvHandler: CsvHandler = CsvHandler()
        try:
            with open(self.script_path, 'rb') as binary_file:
                while True:
                    data = binary_file.read(64)
                    if not data:
                        break
                    # 将字节数据按每个字节拆分并写入 CSV
                    hex_data = [f'{byte:02X}' for byte in data]
                    # 输出一条结果
                    self.csvHandler.runData.append(hex_data)
            sedMsg = f"数据已成功保存到 {self.script_new_path}"
        except FileNotFoundError:
            sedMsg = f"错误：未找到文件 {self.script_path}"
        except Exception as e:
            sedMsg = f"发生了意外错误：{e}"
        if self.script_new_path:
            self.csvHandler.save_csv(filename=self.script_new_path, listData=self.csvHandler.runData)
            sedMsg = '文件已保存：{}'.format(str(self.script_new_path))
        dictData = {"data": sedMsg, "type": f"status_show"}
        self.SendDataHandle(dictData)
        self.statusbar.showMessage(sedMsg)
        time.sleep(0.500)
        self.script_path = self.script_new_path
        self.ParseCSVPCFun()

    def ParseLogPCFun(self):
        if self.script_path is None:
            sedMsg = '未打开 目标文件！！！'
            dictData = {"data": sedMsg, "type": f"status_show"}
            self.SendDataHandle(dictData)
            self.statusbar.showMessage(sedMsg)
            return
        try:
            self.ParseCSVPCFun()
        except Exception as e:
            sedMsg = f"error: {e}"
            dictData = {"data": sedMsg, "type": f"status_show"}
            self.SendDataHandle(dictData)
            self.statusbar.showMessage(sedMsg)

    def ParseLogHostFun(self):
        if self.script_path is None:
            sedMsg = '未打开 目标文件！！！'
            dictData = {"data": sedMsg, "type": f"status_show"}
            self.SendDataHandle(dictData)
            self.statusbar.showMessage(sedMsg)
            return
        try:
            self.ParseLogBINFun()
            self.script_path = ""
            self.lineEditLogPath.setText(self.script_path)
        except Exception as e:
            sedMsg = f"error: {e}"
            dictData = {"data": sedMsg, "type": f"status_show"}
            self.SendDataHandle(dictData)
            self.statusbar.showMessage(sedMsg)

    # def closeEvent(self, event):
    #     """
    #     防止误触关闭程序
    #     :param event:
    #     :return:
    #     """
    #     # 创建一个确认退出的对话框
    #     reply = QMessageBox.question(
    #         self, "Confirmation", "Are you sure you want to exit?",
    #         QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No, QMessageBox.StandardButton.No
    #     )
    #     if reply == QMessageBox.StandardButton.Yes:
    #         self.CleanupSelf()
    #         # 用户确认退出，关闭应用
    #         event.accept()
    #     else:
    #         event.ignore()


# 程序入口，测试当前插件文件使用
if __name__ == "__main__":
    app = QApplication(sys.argv)
    font = QFont("宋体")
    pointsize = font.pointSize()
    font.setPixelSize(int(pointsize * 90 / 72))
    app.setFont(font)
    myWindow = IICLogParseWindow()
    myWindow.setWindowTitle("IICLogParseWindow-2.1")
    myWindow.show()
    sys.exit(app.exec())
